package com.jt.sso.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper {
    /**
     * 基于用户名查询用户信息
     * */
    @Select("select * from sys_user where username=#{username}")
    Map<String,Object> selectUserByUsername(@Param("username") String username);

    @Select("select m.permission "+
            "from sys_user u left join sys_user_role ur on u.id=ur.user_id"+
            " left join sys_role_menu rm on ur.role_id = rm.role_id"+
            " left join sys_menu m on rm.menu_id=m.id "+
            " where u.id=#{id}")
    List<String> selectUserPermissions(@Param("id") Long id);

}
